#include"headers.h"
#include"music.h"

void Music::load()
{
    if(Type == 1) { music = load_midi( file.c_str() ); } //loads the music
    if(Type == 2) {sound = load_sample(file.c_str() ); }
}

Music::Music(string File, int type)
{
    file = File; //assigns the string to what were going to load the music from
    Type = type;
}
Music::~Music()
{
    destroy_midi(music); //deletes the sound to prevent memory leaks
    destroy_sample(sound);
}
void Music::stop()
{
    if(Type == 1) { stop_midi(); } // stops what ever is currently playing
    if(Type == 2) { stop_sample(sound); }
}

void Music::play(bool loop)
{
    if(Type == 1) { play_midi(music, loop); } //plays music

    if(Type == 2) {play_sample(sound,255,128,1000,loop); } //plays sound
}
